package cate.game.activity.treasure.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.treasure.TreasureActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTreasure;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "宝藏抽奖 请求")
public class TreasureDrawReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;

    @NoteField("类型")
    public int type;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        TreasureActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<TreasureActivity> result = single.draw(type);
        if (!result.ok()) {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTreasure.TREASURE_DRAW_REQ;
    }
}
